<?php use_helper("PA_Links") ?>
<?php if(isset($items) && isset($result)): ?>
<form action="<?php echo link_to_app('Production', 'createYawalDemand') ?>" method="post">
<table id="inline_table">
  <th>Lp.</th>
  <th>Symbol</th>
  <th>Nazwa</th>
  <th>Długość</th>
  <th>Ilość (zamówienie)</th>
  <th>Magazyn (bez rezerwacji)</th>
  <th>Ilość do zamówienia</th>
  <th>Info</th>
  <th>Włącz</th>
  <?php foreach($items as $symbol => $data): ?>
  <tr>
    <td><p id="counter"></p></td>
    <td><?php echo $symbol ?></td>
    <td><?php echo isset($result["names"][$symbol]) ? $result["names"][$symbol] : "-" ?></td>
    <td><?php echo $data["Długość"] == 0 ? "-" : $data["Długość"]." mm" ?></td>
    <td style="color: #777777"><?php echo $data["Ilość"] ?>&nbsp;szt.</td>
    <?php if(isset($result["data"][$symbol])): ?>
    <td style="color: #777777"><?php echo $data["Ilość"] + $result["data"][$symbol] ?>&nbsp;szt.</td>
    <!-- Ilosc do zamowienia -->
    <td>
      <input type="hidden" name="quantities[<?php echo $result["ids"][$symbol] ?>]" value="<?php echo $result["data"][$symbol] >= 0 ? "0" : (-1) * ($result["data"][$symbol])?>" />
      <?php printf("%d", ($result["data"][$symbol] >= 0 ? "0" : (-1) * ($result["data"][$symbol]))) ?>&nbsp;szt.
    </td>
    <?php else: ?>
    <td>-</td>
    <td>-</td>
    <?php endif; ?>
    <td>
      <?php if(isset($result["errors"][$symbol])): ?>
      <span style="color:red"><?php echo $result["errors"][$symbol] ?></span>
      <?php else: ?>
      <span id="status_3">OK</span>
      <?php endif; ?>
    </td>
    <td><?php if(!count($result["errors"])): ?><input type="checkbox" name="include[<?php echo $result["ids"][$symbol] ?>]" checked="checked" /><?php else: ?> - <?php endif; ?></td>
  </tr>
  <?php /* ?>
  <tr>
    <td><input type="text" size="18" name="description[<?php echo $result["ids"][$symbol] ?>] " /></td>
  </tr>
  <?php */ ?>
  <?php endforeach; ?>
  <?php if(count($result["errors"])): ?>
  <tr>
    <td colspan="9">
    Nie można zapisać zapotrzebowania ponieważ wystąpiły błędy.
    </td>
  </tr>
  <?php else: ?>
  <?php foreach($projectForm as $field): ?>
  <tr>
    <th><?php echo $field->renderLabel()?></th>
    <td colspan="8"><?php echo $field->render()  ?></td>
  </tr>
  <?php endforeach; ?>
  <tr>
    <td colspan="9"><input type="button" onclick="App.Form.validateYawalXls(); submit();" value="Zapisz" /></td>
  </tr>
  <?php endif; ?>
</table>
</form>
<?php else: ?>
Błąd wczytywania pliku.
<?php endif; ?>
